import { GTextFormat } from "../../../common/GTextFormat";
import { Language } from "../../../../extend/language/Language";
import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { EToplistType } from "../../../../Message/Public/EToplistType";
import { GuildWarRankItem } from "./GuildWarRankItem";
type int = number;
//class GuildWarRankSprite
    
    export  class GuildWarRankSprite /* flash.display.Sprite */
    {
        constructor()
        {
            
            this._itemArr = [];
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            this._headTf = new GTextFormat("", 12, 16777113);
            this._rankTxt = this.createTxt(0, 0, 30, 30, Language.getString(32063));
            this._nameTxt = this.createTxt(85, 0, 50, 30, Language.getString(32064));
            this._campTxt = this.createTxt(165, 0, 30, 30, Language.getString(32067));
            this._levelTxt = this.createTxt(240, 0, 60, 30, "助攻数");
            this._attributeTxt = this.createTxt(280, 0, 50, 30, Language.getString(32099));
            this._attributeTxt2 = this.createTxt(330, 0, 55, 30, Language.getString(32098));
            this._rangeTxt = this.createTxt(405, 0, 60, 30, Language.getString(32070));
            var loc1=ObjCreate.createBg(0, 23, 460, 2, this, ImagesConst.SplitLine);
            this.createItem();
            return;
        }

        /* internal  */createTxt(arg1: int, arg2: int, arg3: int, arg4: int, arg5: string): Object /* flash.text.TextField */
        {
            var loc1;
            (loc1 = new Object /* flash.text.TextField */()).x = arg1;
            loc1.y = arg2;
            loc1.width = arg3;
            loc1.height = arg4;
            loc1.selectable = false;
            loc1.defaultTextFormat = this._headTf;
            loc1.text = arg5;
            addChild(loc1);
            return loc1;
        }

        public resetTextPos(arg1: int): void
        {
            var loc1=arg1;
            switch (loc1) 
            {
                case EToplistType._EToplistTypeGuildWarPlayerMerits:
                {
                    this._nameTxt.text = Language.getString(32064);
                    this._campTxt.text = Language.getString(32067);
                    this._levelTxt.text = Language.getString(32105);
                    this._attributeTxt.text = Language.getString(32099);
                    this._attributeTxt2.text = Language.getString(32098);
                    this._levelTxt.x = 220;
                    this._attributeTxt.x = 280;
                    this._attributeTxt2.x = 330;
                    break;
                }
                case EToplistType._EToplistTypeGuildWarGuildMark:
                {
                    this._nameTxt.text = Language.getString(32067);
                    this._campTxt.text = Language.getString(32068);
                    this._levelTxt.text = Language.getString(32069);
                    this._attributeTxt.text = Language.getString(32073);
                    this._attributeTxt2.text = Language.getString(32106);
                    this._levelTxt.x = 225;
                    this._attributeTxt.x = 280;
                    this._attributeTxt2.x = 340;
                    break;
                }
                case EToplistType._EToplistTypeGuildWarGuildMarkWeek:
                {
                    this._nameTxt.text = Language.getString(32067);
                    this._campTxt.text = Language.getString(32068);
                    this._levelTxt.text = Language.getString(32069);
                    this._attributeTxt.text = Language.getString(32100);
                    this._attributeTxt2.text = "";
                    this._levelTxt.x = 225;
                    this._attributeTxt.x = 310;
                    break;
                }
            }
            this._type = arg1;
            return;
        }

        /* internal  */createItem(): void
        {
            var loc3=null;
            var loc1=0;
            var loc2=30;
            var loc4=0;
            while (loc4 < 10) 
            {
                loc3 = new GuildWarRankItem();
                loc3.x = loc1;
                loc3.y = loc2;
                loc2 = loc2 + loc3.height;
                this._itemArr.push(loc3);
                loc3.addEventListener(flash.events.MouseEvent.CLICK, this.onMouseClickHandler);
                addChild(loc3);
                ++loc4;
            }
            return;
        }

        /* internal  */onMouseClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=null;
            var loc2=0;
            while (loc2 < 10) 
            {
                loc1 = this._itemArr[loc2] as GuildWarRankItem;
                if (loc1.isDraw) 
                {
                    loc1.clearBgColor();
                }
                ++loc2;
            }
            loc1 = arg1.target as GuildWarRankItem;
            if (loc1.sEntityId != null) 
            {
                loc1.drawGrayColor();
            }
            return;
        }

        public setData(arg1: Array<any>): void
        {
            var loc1=null;
            var loc2=0;
            while (loc2 < 10) 
            {
                loc1 = this._itemArr[loc2] as GuildWarRankItem;
                loc1.updateItem(arg1[loc2], this._type);
                if (loc1.isDraw) 
                {
                    loc1.clearBgColor();
                }
                ++loc2;
            }
            if (this._itemArr && this._itemArr.length > 0) 
            {
                loc1 = this._itemArr[0] as GuildWarRankItem;
                if (loc1.sEntityId != null) 
                {
                    loc1.drawGrayColor();
                }
            }
            return;
        }

        public showTargetPlayer(arg1: int): void
        {
            var loc1=null;
            var loc2=0;
            while (loc2 < 10) 
            {
                loc1 = this._itemArr[loc2] as GuildWarRankItem;
                if (loc1.isDraw) 
                {
                    loc1.clearBgColor();
                }
                if (loc1.rank == arg1) 
                {
                    loc1.drawGrayColor();
                }
                ++loc2;
            }
            return;
        }

        /* internal */ /* var */_headTf: Object /* flash.text.TextFormat */;

        /* internal */ /* var */_rankTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_nameTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_campTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_levelTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_attributeTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_attributeTxt2: Object /* flash.text.TextField */;

        /* internal */ /* var */_rangeTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_type: int=901;

        /* internal */ /* var */_itemArr: Array<any>;
    }
